package com.rhb.af.web.tiles;

import java.io.IOException;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.tiles.ComponentContext;
import org.apache.struts.tiles.Controller;
import org.apache.struts.tiles.actions.TilesAction;

import com.rhb.af.web.struts.util.Navicert;


public class DynaTilesController extends TilesAction implements Controller {

	@Override
	public void execute(ComponentContext arg0, HttpServletRequest arg1, HttpServletResponse arg2, ServletContext arg3) throws Exception {
		System.out.println("*******************  com.rhb.af.web.tiles.DynaTilesController.execute()");

	}

	@Override
	public void perform(ComponentContext arg0, HttpServletRequest arg1, HttpServletResponse arg2, ServletContext arg3) throws ServletException, IOException {
		System.out.println("*******************  com.rhb.af.web.tiles.DynaTilesController.perform()");

	}
	
	
	public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
		
		ComponentContext context = ComponentContext.getContext(request);
		if(context == null){
			System.out.println("**********  context is NULL");
		}else{
			Navicert navicert = (Navicert)request.getAttribute("navicert");
			if (navicert == null) {
				navicert = (Navicert) request.getSession().getAttribute("navicert");
			}
			
			if(navicert == null){
				System.out.println("****************   navicert is NULL in DynatilesController");
			}else{
				//System.out.println("navicert.getForward.getName()=" + navicert.getForward().getName());
				//System.out.println("navicert.getForward.getPath()=" + navicert.getForward().getPath());
				//context.putAttribute("body", navicert.getForward().getPath());
			}
		}
		return null;
	}

}
